<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <h1>{{tname | capitalize}}</h1>
    <h1>{{myname| capitalize}}</h1>
    <h1>{{num|two|cheng}}</h1>
  </div>
  <div id="con"></div>
  <script src="./vue.js"></script>
  <script>
    //vue的过滤器 是管道写法  对数据渲染进行处理
    // 首字母大写的过滤器
    Vue.filter('capitalize', function (value) {
      if (!value) return ''
      value = value.toString();
      return value.charAt(0).toUpperCase() + value.substr(1)
    })
    var vm = new Vue({
      el: "#app",
      data() {
        return {
          tname: "john",
          myname: "green",
          num: 1123.232332
        }
      },
      // 局部过滤器
      filters: {
        two: function (value) {
          return value.toFixed(2) //保留俩位小数点
        },
        cheng: function (value) {
          return value * 10
        }
      }
    })



  </script>
</body>

</html>